home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 338_01 / aserr.c < prev    next >
Text File  |  1989-11-29  |  3KB  |  115 lines

  1. /* aserr.c - report the error to all open error channels */
  2. #include <stdio.h>
  3. #include "as68.h"
  4.  
  5. /* externs */
  6.  
  7. extern unsigned line_count;
  8. extern unsigned list_count;
  9. extern FLAG econ;
  10. extern FLAG elst;
  11. extern FLAG efile;
  12. extern FLAG elfile;
  13. extern FILE *err_f;
  14. extern FILE *lst_d;
  15. extern FILE *lst_f;
  16. extern int src_level;
  17. extern char pass;
  18.  
  19. /* text for errors */
  20.  
  21. static char *err_msg[] = {
  22.     "?",                    /* no error #0 */
  23.     "Parsing error - totally confused!!",    /* #1 */
  24.     "Bad character in mnemonic/pseudo-op",    /* #2 */
  25.     "Unknown instruction or pseudo-op",
  26.     "Bad character in macro",            /* Macros not implimented */
  27.     "Macro not known",
  28.     "Improper use of label",
  29.     "Can't evaluate operand",
  30.     "Can't evaluete EQU operand",
  31.     "Can't evaluate SET operand",
  32.     "Can't redefine permanent symbol",
  33.     "Symbol table full",
  34.     "Unrecognized operand",
  35.     "Symbol not defined/forward ref?",
  36.     "Label out of range",
  37.     "Operand 1 not valid for this opcode",
  38.     "Operand 2 not valid for this opcode",
  39.     "Operand 1 not correctly formed",
  40.     "Operand 2 not correctly formed",
  41.     "Can't build code?",
  42.     "3-bit immediate out of bounds",
  43.     "8-bit specifier out of range",
  44.     "32-bit specifier out of range",
  45.     "Can't generate bit-field specifier",
  46.     "Count operand out of range",
  47.     "25 destination register out of range",
  48.     "Illegal register specifier",
  49.     "Can't generate register mask list",
  50.     "Doesn't evaluate to effective address",
  51.     "Illegal effective address",
  52.     "Illegal destination address",
  53.     "Illegal multiple destination address",
  54.     "Illegal jump address",
  55.     "4-bit vector out of range",
  56.     "Address displacement doesn't evaluate",
  57.     "8-bit displacement out of range",
  58.     "16-bit displacement out of range",
  59.     "Extent word doesn't evaluate correctly",
  60.     "8-bit operand out of range",
  61.     "8-bit extension word out of range",
  62.     "16-bit extension word out of range",
  63.     "32-bit extension word overflow",
  64.     "16-bit displacement failed - overflow?",
  65.     "8-bit displacement failed - overflow?",
  66.     "Include error - can't open file",
  67.     "Phase error - label value different on pass 2"
  68.     };
  69.  
  70. err_out(err_num)
  71. int err_num;
  72. {
  73.     register int x, y;
  74.     char buf[85];
  75.     extern int err_stk[MAXERR];    /* these two used to be 'static', moved to */
  76.     extern int err_sp;        /*  root for overlay purposes */
  77.     extern FLAG any_errors;    /* just to speed things up in overlay env */
  78.  
  79.     switch (err_num) {
  80.     case NULL:
  81.     for (x = MAXERR; --x >= err_sp; ) {
  82.         y = -(err_stk[x]) - 100;
  83.         if (pass == 1) {
  84.         sprintf(buf, "Pass 1 error #%d at %d\n", y, line_count);
  85.         } else {
  86.             if( line_count != 1 ) {
  87.                 sprintf(buf, "Error #%d at %d (%s)\n", y, line_count, err_msg[y]);
  88.                 printf("Error on Line %d: %s\n", line_count, err_msg[y]);
  89.             }
  90.             else
  91.                 sprintf(buf, "");
  92.         }
  93.         if (econ) {    puts(buf); }
  94.         if (elst) { fputs(buf, lst_d); }
  95.         if (elfile)    { fputs(buf, lst_f); }
  96.         if (efile)
  97.         {   fprintf(err_f, ">> level: %d, line: %d\n", src_level + 1, line_count);
  98.             fputs(buf, err_f);
  99.         }
  100.     }            /* fall through to FLUSH */
  101.     case FLUSH:
  102.     err_sp = MAXERR;                    /* reset */
  103.     any_errors = NO;
  104.     break;
  105.     default:
  106.     any_errors = YES;
  107.     if (err_sp) {
  108.         err_stk[--err_sp] = err_num;
  109.     }
  110.     }
  111.     return err_num;
  112. }
  113.  
  114.  
  115.